<!--
 * @Author: WangShuai 1830773767@qq.com
 * @Date: 2025-06-11 14:15:10
 * @LastEditors: WangShuai 1830773767@qq.com
 * @LastEditTime: 2025-06-11 18:36:11
 * @FilePath: \vue3_admin_template\project\src\views\screen\component\Sex\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="box1">
    <p class="title">男女比例</p>
    <p class="bg"></p>
    <div class="sex">
      <div class="man">
        <img src="../../images/man.png" alt="" />
      </div>
      <div class="women">
        <img src="../../images/woman.png" alt="" />
      </div>
    </div>
    <div class="rate">
      <P>男士58%</P>
      <P>女士42%</P>
    </div>
    <div class="echart" ref="echart"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
//获取图形图表的DOM节点
let echart = ref()
onMounted(() => {
  //初始化Echarts实例
  let myEcharts = echarts.init(echart.value)
  myEcharts.setOption({
    title: {
      text: '男女比例',
      textStyle: {
        color: 'skyblue',
      },
      left: '40%',
    },
    xAxis: {
      //   type: 'category',
      show: false,
    },
    yAxis: {
      //   type: 'value',
      show: false,
      type: 'category',
    },
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: '20',
        barGap: '0%',
        z: 100, //显示层级  越大会把值小的覆盖
        itemStyle: {
          color: 'skyblue',
          borderRadius: 20,
        },
      },
      {
        type: 'bar',
        data: [100],
        barWidth: '20', //柱状图每个柱子宽度
        barGap: '-100%', //调整女士柱状图位置
        borderRadius: 20,
        itemStyle: {
          color: 'pink',
          borderRadius: 20,
        },
      },
    ],
    grid: {
      top: 0,
      bottom: 0,
      left: 0,
      right: 0,
    },
  })
})
</script>

<style lang="scss" scoped>
.box1 {
  margin: 10px 0px 0 0;
  width: 100%;
  height: 100%;
  background: url('../../images/dataScreen-main-cb.png') no-repeat;
  background-size: 100% 100%;
  .title {
    color: #fff;
    font-size: 20px;
    margin-left: 20px;
  }
  .bg {
    width: 68px;
    height: 7px;
    background: url('../../images/dataScreen-title.png') no-repeat;
    background-size: cover;
    margin: 10px 0 0 20px;
  }
  .sex {
    margin-top: 40px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    .man {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 115px;
      height: 115px;
      background: url('../../images/man-bg.png');
    }
    .women {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 115px;
      height: 115px;
      background: url('../../images/woman-bg.png');
    }
  }
  .rate {
    display: flex;
    justify-content: space-between;
    color: #fff;
  }
  .echart {
    width: 100%;
    height: 100px;
    // background-color: red;
  }
}
</style>
